package com.vpx.server.controller.system;

import com.vpx.server.bean.order.base.BaseDelOrder;
import com.vpx.server.bean.order.base.BaseIdStrOrder;
import com.vpx.server.bean.order.system.BaseInfoAttrOrder;
import com.vpx.server.bean.order.system.BaseInfoAttrPageOrder;
import com.vpx.server.bean.result.system.BaseInfoAttrResult;
import com.vpx.server.bean.result.system.BaseInfoResult;
import com.vpx.server.framework.authority.AuthPoicy;
import com.vpx.server.framework.authority.RequestAuth;
import com.vpx.server.framework.base.BasePageResult;
import com.vpx.server.framework.base.ResultMsg;
import com.vpx.server.service.system.BaseInfoAttrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 基础用例表、分支表、流程项表管理
 */
@RestController
@RequestMapping(value = "/api/baseInfoId")
@Api(tags = "基础用例表、分支表、流程项表管理")
public class BaseInfoAttrController {

    @Autowired
    private BaseInfoAttrService baseInfoAttrService;

    @PostMapping("/insertBaseInfoAttr")
    @ApiOperation("新增测试项属性")
    public ResultMsg insert(@Validated @RequestBody BaseInfoAttrOrder order) {
        return baseInfoAttrService.saveBaseInfoAttr(order);
    }

    @PostMapping("/batchInsertBaseInfoAttr")
    @ApiOperation("批量新增测试项属性")
    public ResultMsg batchInsertBaseInfoId(@Validated @RequestBody List<BaseInfoAttrOrder> orders) {
        return baseInfoAttrService.batchInsertBaseInfoAttr(orders);
    }

    @DeleteMapping("/deleteBaseInfoAttr")
    @ApiOperation("删除测试项属性")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg deleteBaseInfoId(@Validated @RequestBody BaseDelOrder order) {
        return baseInfoAttrService.deleteBaseInfoAttr(order);
    }

    @PostMapping("/updateBaseInfoAttr")
    @ApiOperation("修改")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg updateById(@RequestBody BaseInfoAttrOrder order) {
        return baseInfoAttrService.updateBaseInfoAttrById(order);
    }

    @GetMapping("/selectBaseInfoIdByAttr")
    @ApiOperation("查询详情")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg<BaseInfoAttrResult> selectById(BaseIdStrOrder order) {
        return baseInfoAttrService.selectBaseInfoAttrById(order);
    }

    @GetMapping("/pageQueryBaseInfoAttr")
    @ApiOperation("分页查询")
    //@RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg<BasePageResult<BaseInfoResult>> pageQueryBaseInfoId(BaseInfoAttrPageOrder order) {

        return baseInfoAttrService.pageQueryBaseInfoAttr(order);
    }


}
